package com.cn.dao;
import com.cn.entity.UserAccount;
import com.cn.util.DBUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class QueryAccount {
    static  ResultSet rs=null;
    static UserAccount userAccount=null;
    public static UserAccount getQueryAccount(int userid){
        String sql="select * from UserAccount where userId=?";
        Object[] obj={userid};
        rs=DBUtil.query(sql,obj);
        if(rs!=null) {
            try {
                if (rs.next()) {
                    int id1 = rs.getInt("id");
                    int userid1 = rs.getInt("userid");
                    int taocanod1 = rs.getInt("taocanid");
                    String tcname1 = rs.getString("taocanname");
                    int tonghua1 = rs.getInt("tonghua");
                    double ban1 = rs.getDouble("balance");
                    int liuliang1 = rs.getInt("liuliang");
                    int message1 = rs.getInt("message");
                    userAccount = new UserAccount(id1, userid, taocanod1, tcname1, tonghua1, ban1, liuliang1, message1);
                }
            } catch (SQLException e) {
                e.printStackTrace();
                return null;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
        return userAccount;
    }

}
